﻿using Robocode;
using System;

namespace BattleBotsMattAndSunny.Model
{
    public class Enemy
    {
        public string Name { get; set; }

        public double X { get; set; }

        public double Y { get; set; }

        public double Velocity { get; set; }

        public double HeadingRadians { get; set; }

        public double Bearing { get; set; }

        public double Distance { get; set; }

        public double AbsoluteBearingRadians { get; set; }

        public double? HeadingChange { get; set; }

        public double? PreviousEnergy { get; set; }

        public double Energy { get; set; }

        public Enemy()
        {
        }

        public Enemy(ScannedRobotEvent e, AdvancedRobot robot)
        {
            if (e != null && robot != null)
            {
                X = robot.X + e.Distance * Math.Sin(e.BearingRadians);
                Y = robot.Y + e.Distance * Math.Cos(e.BearingRadians);
                Velocity = e.Velocity;
                HeadingRadians = e.HeadingRadians;
                Distance = e.Distance;
                AbsoluteBearingRadians = HeadingRadians + e.BearingRadians;
                Name = e.Name;
                Bearing = e.Bearing;
                Energy = e.Energy;
            }
        }
    }
}